{$CLEO .qa}
{$USE CLEO+}
{$USE Audio}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "TRSHPQA"

// By ArtemQa146

const
    trash_man = 31@
    trach_can = 30@
    find = 29@
    progress = 28@
    find_ped = 27@
    redner_ped = 26@
    coords_x = 25@
    coords_y = 24@
    coords_z = 23@
    angle_z = 22@
    pause_start = 21@
    pause_stop = 20@
    chanse_time_trash = 0@
end

progress = 0

while true
wait 500
    if
        player.Defined(0)
    then
        find = 0
        while get_any_object_no_save_recursive find progress_to find object_to trach_can
            if
                09CC:   object trach_can model_is 1344
            then
                if and
                    not is_object_script_controlled trach_can
                    0EE6: locate_char_distance_to_object $player_actor object trach_can radius 35.0
                    not locate_char_distance_to_object $player_actor object trach_can radius 10.0
                    82CC:   not object trach_can bounding_sphere_visible
                then
                    0400: store_coords_to 1@ 2@ 3@ from_object trach_can with_offset 0.0 0.0 0.0
                    0AE1: trash_man = random_char_near_point 1@ 2@ 3@ in_radius 100.0 find_next 1 pass_deads 1
                    if
                        056D:   actor trash_man defined
                    then
                        0EFF: get_char_simplest_active_task trash_man id_to 1@ pointer_to 2@
                        if and
                            1@ == 900
                            82CB:   not actor trash_man bounding_sphere_visible
                            not is_char_script_controlled trash_man
                            80DF:   not actor trash_man driving
                        then
                            089F: get_actor trash_man pedtype_to 1@
                            if or
                                1@ == 4
                                1@ == 5
                            then
                                repeat
                                wait 0
                                04ED: load_animation  "PedEventsMod"
                                until 04EE:   animation "PedEventsMod" loaded

                                if and
                                    056D:   actor trash_man defined
                                    03CA:   object trach_can exists
                                then
                                    0208: 4@ = random_float_in_ranges -3.0 3.0
                                    0400: store_coords_to 1@ 2@ 3@ from_object trach_can with_offset 4@ -3.5 0.0
                                    0400: store_coords_to coords_x coords_y coords_z from_object trach_can with_offset 0.0 -1.0 0.0
                                    00A1: put_actor trash_man at 1@ 2@ 3@
                                    0E24: fix_char trash_man ground 1 brightness 1 and_fade_in 0
                                    0176: 1@ = object trach_can Z_angle
                                    0176: angle_z = object trach_can Z_angle
                                    0173: set_actor trash_man Z_angle_to 1@
                                    0792: disembark_instantly_actor trash_man
                                    0812: AS_actor trash_man perform_animation "stand_1" IFP "PedEventsMod" framedelta 1000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB
                                    model.Load(1265)
                                    if
                                        not model.Available(1265)
                                    then
                                        repeat
                                        wait 0
                                        model.Load(1265)
                                        until model.Available(1265)
                                    end
                                    038B: load_requested_models
                                    0E2E: create_render_object_to_char_bone trash_man model 1265 bone 24 offset 0.15 0.0 0.0 rotation 0 0 0 store_to redner_ped
                                    0E37: set_render_object_scale redner_ped 0.4 0.4 0.4
                                    model.Destroy(1265)
                                    progress = 0

                                    repeat
                                    wait 0
                                    if
                                        056D:   actor trash_man defined
                                    then

                                        080E: get_actor trash_man ped_event_to 1@
                                        if or
                                            1@ == 49
                                            1@ == 9
                                            051A:   actor trash_man damaged_by_actor $PLAYER_ACTOR
                                            not $ACTIVE_INTERIOR == 0
                                            0118:   actor trash_man dead
                                            not locate_char_distance_to_coordinates trash_man pos coords_x coords_y coords_z radius 7.0
                                            not locate_char_distance_to_char $player_actor char trash_man radius 100.0
                                        then
                                            break
                                        end


                                        if and
                                            progress == 0
                                            02CB:   actor trash_man bounding_sphere_visible
                                        then
                                            0792: disembark_instantly_actor trash_man
                                            0615: define_AS_pack_begin 1@
                                            07CD: AS_actor -1 walk_to coords_x coords_y coords_z stop_with_angle angle_z within_radius 1.0
                                            0812: AS_actor -1 perform_animation "peds_trash" IFP "PedEventsMod" framedelta 2.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1  // versionB
                                            0616: define_AS_pack_end 1@
                                            0618: assign_actor trash_man to_AS_pack 1@
                                            061B: remove_references_to_AS_pack 1@
                                            progress = 1
                                        end
                                        if and
                                            progress == 1
                                            0611:   actor trash_man performing_animation "peds_trash"
                                        then
                                            0613: 1@ = actor trash_man animation "peds_trash" time
                                            if
                                                1@ > 0.35
                                            then
                                                0E31: set_render_object_visible redner_ped 0
                                                progress = 2
                                            end
                                        end
                                        if
                                            progress == 2
                                        then
                                            if
                                                0611:   actor trash_man performing_animation "peds_trash"
                                            then
                                            else
                                                break
                                            end
                                        end

                                    else
                                        break
                                    end
                                    until not player.Defined(0)
                                end
                                04EF: release_animation "PedEventsMod"
                                wait chanse_time_trash
                                0A93: terminate_this_custom_script
                            end
                        end
                    end
                end
            end
        end
    end
end